import { createApp, createVNode } from 'vue'
import App from './App.vue'
import router from './router/index'
import { store, key } from './store/index'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//引入图标
import * as Icons from '@element-plus/icons-vue'
const app = createApp(App);
app.use(router).use(store, key).use(ElementPlus).mount('#app')

//方式一：
// typeof 和 keyof
const person = {
    name: '张三',
    age: 18
}
//typeof获取一个对象的类型
type tp = typeof person;
//keyof获取某种类型的所有键（key），返回的类型是一个联合类型
type keys = keyof tp;
//全局注册组件
// Object.keys(Icons).forEach((key)=>{
//     console.log(key)
//     app.component(key,Icons[key as keyof typeof Icons])
//     // app.component(key,Icons[key])
// })
// 方式二
const Icon = (props: { icon: string }) => {
    const { icon } = props;
    return createVNode(Icons[icon as keyof typeof Icons]);
};
app.component('Icon', Icon);
